<?php
namespace app\index\validate;
use think\Validate;

class Users extends Validate{
    protected $rule = [
        ['username','require|min:5','必须填写用户名|最少5个单位'],
        ['user_email','require|email','邮箱必须填写'],
        ['password','require|min:6','必须填写密码|密码最少6位'],
        ['repassword','require|confirm:password','必须填写确认密码|两次密码不一致'],
        ['user_phone','number|length:11','手机号格式错误'],
        ['agree_clause','require|accepted','必须同意服务条款|必须同意服务条款'],
        ['captcha', 'require|captcha','必须填写验证码|验证码错误'],
        ['realname', 'chs','请输入中文名字'],
        ['usersex', 'in:1,2'],
        ['user_qq', 'number|length:5,12', 'QQ号码只能为数字|QQ号码只能为5-12位'],
    ];
    // 验证规则

    // 场景设置
    protected $scene = [
        'register' => ['name', 'user_email', 'password', 'repassword', 'user_phone', 'agree_clause', 'captcha'], //注册场景
        'login' => ['username', 'password'],//登陆场景
        'update' => ['user_phone', 'realname', 'usersex', 'user_qq'], //更新数据场景
        'changepassword' => ['password', 'repassword'], //更改密码场景
    ];
}
